export const useListLoad = getData => {
  const dataList = ref([])
  const keywords = ref('')
  const pageNum = ref(0)
  const pageSize = ref(15)
  const isLoadAll = ref(false)
  const loading = ref(false)

  const reset = () => {
    dataList.value = []
    pageNum.value = 1
    isLoadAll.value = false
  }

  const loadMore = async () => {
    if (isLoadAll.value) return
    pageNum.value++
    getData && (await getData())
  }

  return {
    loading,
    dataList,
    keywords,
    pageNum,
    pageSize,
    isLoadAll,
    reset,
    loadMore
  }
}
